package com.csaba.connector.khb;

import java.util.logging.Logger;

import com.csaba.connector.ServiceException;
import com.csaba.connector.khb.model.KHBBank;
import com.csaba.connector.khb.model.KHBSession;
import com.csaba.connector.model.Session;
import com.csaba.connector.service.AbstractBankService;
import com.csaba.connector.service.LogoutService;
import com.csaba.util.LoggerHelper;

public class KHBLogoutService extends AbstractBankService implements LogoutService, Codes
{
	private final static Logger logger = LoggerHelper.getDefaultLogger();

	@Override
	public void execute( final Session session ) throws ServiceException
	{
		if ( !( session instanceof KHBSession ) )
			throw new ServiceException("Incompatible session " + KHBBank.class + " != " + session.getClass().getName());
		logger.fine("KHB Logout");

		final KHBSession khb = (KHBSession) session;

		final String logoutResult = khb.doGet(Codes.URL_RETAIL_ROOT + "?fun=" + FUN_LOGOUT);
		khb.debugFile("logout", logoutResult);

		final String logout2Result = khb.doGet(Codes.URL_RETAIL_ROOT + "?fun=" + FUN_LOGIN_INDEX);
		khb.debugFile("logout2", logout2Result);
	}

}
